{if $ajax}
<?php ob_start(); ?>

{"code":0,"msg":"","count":1000,"data":[

		
		{foreach $op as $k => $v}
				{"id":"{$v.unique_id}","name":"{$v.name}","desc":"{$v.desc}","other":"{$v.other}",
				"porder":"{$v.porder}","status":"{$v.status}","is_admin":"{$v.is_admin}",
				"module_id":"{$v.id}","method" : "{$v.method}","no" :"{$k+1}"
				},
			{/foreach}

<?php
$a = trim(ob_get_contents());
ob_clean();
echo substr($a,0,-1);
?>
]}

<?php exit;?>
{/if}
<a class="layui-btn  add_op2" lay-event="detail" data="{$id}">添加操作</a>

<table lay-filter="main_table2_filter" class="layui-table" id="main_table2" style="margin:0px;">
</table>

<script>
layui.use(['table','layer'], function(){
  var table = layui.table, $ = layui.$ , layer = layui.layer;
	/*  //转换静态表格
	table.init('demo', {	
	  //支持所有基础参数
	}); 
	*/
	/*输出*/
	var tableIns = table.render({
		elem:'#main_table2',
		
		cols:  [[ 
    {field: 'no', title: '序号', width: 80,sort:true}
    ,{field: 'method', title: '唯一标识', width: 100,sort:true,edit:'text'}
    ,{field: 'name', title: '操作名称', width: 120,sort:true,edit:'text'}

   /* ,{field: 'desc', title: '操作简介', width: 200,edit:'text'}*/
    ,{field: 'status', title: '是否开启', width: 100,sort:true,edit:'text', templet: '#statusTpl'}
    ,{field: 'is_admin', title: '所属位置', width: 100,sort:true,edit:'text', templet: '#is_adminTpl'}
	

	 ,{field: 'porder', title: '排序', width: 80,edit:'text',sort:true}
    ,{field: 'op', title: '操作', width: 300, toolbar: '#barOp'}
  ]],
		/*url : '{_url m="view" id=$id ajax=1}',*/
		done : function(){

			$.each($('.add_op2'),function(){		
				$(this).click(function(){
					openPage('{_url m="addop"}&id='+$(this).attr('data'),'添加'+$(this).attr('data')+'模块下的操作');
				});
			});
			$.each($('.edit_op'),function(){		
				$(this).click(function(){
					openPage('{_url m="editop"}&id='+$(this).attr('data'),'编辑'+$(this).attr('data')+'模块下的操作');
				});
			});

			
		},

		data : [
			{foreach $op as $k => $v}
				{'id':'{$v.unique_id}','name':'{$v.name}','desc':'{$v.desc}','other':'{$v.other}',
				'porder':'{$v.porder}','status':'{$v.status}','is_admin':'{$v.is_admin}',
				'module_id':'{$v.id}','method' : '{$v.method}','no' :'{$k+1}'},
			{/foreach}
		],	
	});


	
	doFastEdit('{_url m="fastop"}', 'main_table2_filter');

	
});

/*<input type="checkbox" name="status" value=1 checked lay-skin="switch">*/
</script>


{html}
<script type="text/html" id="is_adminTpl">
  {{# if (d.is_admin == 1) { }}		
		后台
	{{#  } else { }}
		前台
	 {{#  } }}
</script>
<script type="text/html" id="barOp">
  <a class="layui-btn layui-btn-mini add_op2" lay-event="detail" data="{{d.module_id}}">添加操作</a>
  <a class="layui-btn layui-btn-mini edit_op" lay-event="edit" data="{{d.id}}">编辑操作</a>
  <a class="layui-btn layui-btn-danger layui-btn-mini del" data="{{d.id}}" lay-event="del">删除</a>  

</script>

{/html}
